package com.zang.hash;

/**
 * @author ZVerify
 * @since 2022/10/12 11:03
 **/
public class 赎金信 {

    public boolean canConstruct(String ransomNote, String magazine) {

        int[] map = new int[26];

        for (char c : magazine.toCharArray()) {
            map[c-'a']++;
        }

        for (char c : ransomNote.toCharArray()) {
            map[c-'a']--;
            if (map[c-'a']<0){
                return false;
            }
        }
        return true;
    }
}
